﻿#region Copyrights Notice
//©2010 Microsoft Corporation. All rights reserved.
#endregion

#region usings
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
#endregion

namespace Microsoft.InformationSecurity.CISF.SecurityPortal.UI.WebLibrary
{
    /// <summary>
    /// Custom site map provider to perform role checking.
    /// </summary>
    public class SiteMapProvider : XmlSiteMapProvider
    {
        public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
        {
            if (node.Roles.Contains("*"))
                return true;

            foreach (string roleName in node.Roles)
            {
                if (context.User.IsInRole(roleName))
                {
                    return true;
                }
            }
            return false;
        }
    }
}
